<?php
require_once("init.php");

$user_name=$_POST['user_name'];
$text=$_POST['text'];
$text=str_replace("\\\"","&quot;",$text);
$text=str_replace("\\'","&#39;",$text);
$url="http://twitter.com/direct_messages/new.json";
$post_data=array("user"=>$user_name,"text"=>$text);
foreach ($post_data as $name => $value) {
    $s[] = $name.'='.urlencode($value);
}
$post_data = implode('&', $s);
post_to_twitter($url,$post_data);
header("Location: sent.php");
?>